package com.huaju.enity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * Company entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "company", catalog = "licai")
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class Company implements java.io.Serializable {

	// Fields

	private Integer cid;
	private String cname;
	private String cdesc;
	private Set<Subcompany> subcompanies = new HashSet<Subcompany>(0);

	// Constructors

	/** default constructor */
	public Company() {
	}

	/** full constructor */
	public Company(String cname, String cdesc, 
			Set<Subcompany> subcompanies) {
		this.cname = cname;
		this.cdesc = cdesc;
		this.subcompanies = subcompanies;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "cid", unique = true, nullable = false)
	public Integer getCid() {
		return this.cid;
	}

	public void setCid(Integer cid) {
		this.cid = cid;
	}

	@Column(name = "cname", length = 45)
	public String getCname() {
		return this.cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	@Column(name = "cdesc", length = 65535)
	public String getCdesc() {
		return this.cdesc;
	}

	public void setCdesc(String cdesc) {
		this.cdesc = cdesc;
	}


	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "company")
	public Set<Subcompany> getSubcompanies() {
		return this.subcompanies;
	}

	public void setSubcompanies(Set<Subcompany> subcompanies) {
		this.subcompanies = subcompanies;
	}

}